﻿<phone:PhoneApplicationPage 
	x:Class="UnitDriven.TestEngine"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:System="clr-namespace:System;assembly=mscorlib"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:e="clr-namespace:UnitDriven.Controls"
	xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
	xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	FontFamily="{StaticResource PhoneFontFamilyNormal}"
	FontSize="{StaticResource PhoneFontSizeNormal}"
	Foreground="{StaticResource PhoneForegroundBrush}"
	SupportedOrientations="Portrait"
	Orientation="Portrait"
	mc:Ignorable="d" 
	d:DesignWidth="480" 
	d:DesignHeight="768"
	shell:SystemTray.IsVisible="True">
	<UserControl.Resources> 
		<System:Double x:Key="EllipseRadius">32</System:Double>
		<e:TestStatusConverter x:Key="statusConverter" />
		<e:VisibilityConverter x:Key="visibilityConverter" />

		<ControlTemplate x:Key="StatusButton" TargetType="Button">
			<Ellipse 
				StrokeThickness="1"
				Stroke="{StaticResource PhoneForegroundBrush}"
				Height="{StaticResource EllipseRadius}"
				Width="{StaticResource EllipseRadius}"
				Fill="{Binding Status, Converter={StaticResource statusConverter}}" />
		</ControlTemplate>

		<DataTemplate x:Key="method">
			<Border Padding="20,10,10,10" Visibility="{Binding IsVisible}">
				<StackPanel Orientation="Horizontal">
					<Button 
						Template="{StaticResource StatusButton}"
						Click="Run_Click" 
						IsEnabled="{Binding IsNotRunning}"
						HorizontalAlignment="Left"
						Margin="10,0,0,0" />
					<TextBlock 
						Text="{Binding Name}" 
						VerticalAlignment="Center"
						Style="{StaticResource PhoneTextNormalStyle}" />
					<Button 
						Content="Error" 
						Margin="10,0,0,0"
						VerticalAlignment="Center"
						Visibility="{Binding HasError, Converter={StaticResource visibilityConverter}}"
						Click="ErrorDetails_Click" />
					
				</StackPanel>
			</Border>
		</DataTemplate>

		<DataTemplate x:Key="type">
			<Border Padding="20,10,10,10" Visibility="{Binding IsVisible}" >
				<StackPanel Orientation="Vertical">
					<StackPanel Orientation="Horizontal">
						<Button 
							Click="Run_Click" 
							IsEnabled="{Binding IsNotRunning}"
							Template="{StaticResource StatusButton}"
							HorizontalAlignment="Left"
							Margin="10,0,0,0" />
						<TextBlock 
							VerticalAlignment="Center" 
							Text="Type:"
							Style="{StaticResource PhoneTextNormalStyle}" />
						<TextBlock 
							VerticalAlignment="Center" 
							Text="{Binding Name}"
							Style="{StaticResource PhoneTextNormalStyle}" />
					</StackPanel>
					<ItemsControl 
						ItemTemplate="{StaticResource method}" 
						ItemsSource="{Binding Items}" 
						HorizontalContentAlignment="Stretch" />
				</StackPanel>
			</Border>
		</DataTemplate>
		
		<DataTemplate x:Key="group">
			<Border Padding="20,10,10,10" Background="Transparent" Visibility="{Binding IsVisible}">
				<StackPanel Orientation="Vertical">
					<StackPanel Orientation="Horizontal">
						<Button 
							Click="Run_Click" 
							IsEnabled="{Binding IsNotRunning}"
							Template="{StaticResource StatusButton}"
							HorizontalAlignment="Left"
							Margin="10,0,0,0" />
						<TextBlock 
							VerticalAlignment="Center" 
							Text="{Binding Name}" 
							Style="{StaticResource PhoneTextNormalStyle}" />
					</StackPanel>
					<ItemsControl 
						ItemTemplate="{StaticResource type}" 
						ItemsSource="{Binding Items}"
						HorizontalContentAlignment="Stretch" />
				</StackPanel>
			</Border>
		</DataTemplate>
	</UserControl.Resources>

	<!--LayoutRoot contains the root grid where all other page content is placed-->
	<Grid x:Name="LayoutRoot" Background="Transparent">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<!--TitlePanel contains the name of the application and page title-->
		<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,26,0,12">
			<TextBlock Text="UNIT DRIVEN" Style="{StaticResource PhoneTextNormalStyle}"/>
			<TextBlock Text="testrunner" Margin="-3,-6,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
		</StackPanel>
		
		<!--ContentPanel - place additional content here-->
		<Grid x:Name="ContentGrid" Grid.Row="1">
			<Grid.RowDefinitions>
				<RowDefinition Height="auto" />
				<RowDefinition />
			</Grid.RowDefinitions>

			<StackPanel Grid.Row="0" Orientation="Horizontal">
				<Button Content="Run All" VerticalAlignment="Center" Click="RunAll_Click" IsEnabled="{Binding IsNotRunning}" />
				<TextBlock Text="Test Engine:" VerticalAlignment="Center"/>
				<TextBlock Text="{Binding Succeeded}" Margin="5,0,0,0" VerticalAlignment="Center"/>
				<TextBlock Text="/" Margin="3,0,3,0" VerticalAlignment="Center"/>
				<TextBlock Text="{Binding Total}" VerticalAlignment="Center"/>
				<TextBox 
					x:Name="filterText"
					Text="{Binding Filter, Mode=TwoWay}"
					Width="175"
					Margin="5,10,5,5" 
					VerticalContentAlignment="Center"
					AcceptsReturn="True"
					GotFocus="TextBox_GotFocus" />
			</StackPanel>
			
			<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Visible">
				<ItemsControl 
					x:Name="types"
					Background="Black"
					ItemTemplate="{StaticResource group}"
					ItemsSource="{Binding Items}"
					HorizontalContentAlignment="Stretch" />
			</ScrollViewer>
		</Grid>

		<Border
			VerticalAlignment="Bottom"
			HorizontalAlignment="Stretch"
			BorderThickness="0"
			Background="Black"
			Grid.Row="1"
			Padding="1">
			<Grid>
				<Button
					Click="SummaryCopy_Click"
					Content="Summary" />
			</Grid>
		</Border>

	</Grid>
</phone:PhoneApplicationPage>
